package edu.colorado.karl.databases;

/**
 * Encapsulates a sensor in the trends database.
 * @author Michael Knudson
 * @version 3/9/08
 */
public class SensorResponse {
	private String name;
	private double value;
	
	/**
	 * Instantiates a new <code>SensorResponse</code> with the given values.
	 * @param name	The name of the sensor.
	 * @param value	The value of the sensor.
	 */
	public SensorResponse(String name, double value) {
		this.name = name;
		this.value = value;
	}

	/**
	 * Returns the name of this sensor.
	 * @return the name of this sensor.
	 */
	public String getName() {
		return name;
	}

	/**
	 * Returns the value of this sensor.
	 * @return the value of this sensor.
	 */
	public double getValue() {
		return value;
	}
	
	/**
	 * Returns the value of this sensor as a String with a decimal precision
	 * of one.
	 * @return the value of this sensor as a String.
	 */
	public String getValueString() {
		String s = "" + value;
		
		if(s.indexOf('.') != -1 && (s.length() - s.indexOf('.')) > 2)
			s = s.substring(0, s.indexOf('.')+2);
		
		return s;
	}
}